<?php


class Answer{
	public static function GetAnswer($str){
		$host = "http://jisuznwd.market.alicloudapi.com";
	    $path = "/iqa/query";
	    $method = "GET";
	    $appcode = "d1542bdbe60649fea59c1b4a92b9da7a";
	    $headers = array();
	    array_push($headers, "Authorization:APPCODE " . $appcode);
	    $question = utf8_encode($str);
	    $querys = "question=".$question;
	    $bodys = "";
	    $url = $host . $path . "?" . $querys;

	    $curl = curl_init();
	    curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
	    curl_setopt($curl, CURLOPT_URL, $url);
	    curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
	    curl_setopt($curl, CURLOPT_FAILONERROR, false);
	    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
	    //不要head头部
	    curl_setopt($curl, CURLOPT_HEADER, false); 
	    if (1 == strpos("$".$host, "https://"))
	    {
	        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
	        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
	    }
	    return curl_exec($curl);
	}
}


?>


